package wzc.design_pattern.behaviour.mediator;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author 那和不是个啥
 * @Date 2025/7/20
 * @Description
 */

public class ChatRoom implements Mediator{
    private List<Colleague> colleagues;

    public ChatRoom() {
        colleagues = new ArrayList<Colleague>();
    }

    public void addColleague(Colleague colleague) {
        colleagues.add(colleague);
    }

    @Override
    public void sendMessage(String message, Colleague colleague) {
        for (Colleague c : colleagues) {
            if (c != colleague) {
                c.receive(message);
            }
        }
    }
}
